import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../res/xmm_img.dart';

BoxDecoration commonBgDecoration({String? bgImage}) {
  return BoxDecoration(
    image: DecorationImage(
      image: AssetImage(bgImage ?? XmmImg.commonBg),
      fit: BoxFit.fill,
    ),
  );
}

BoxDecoration radiusDecoration(
    double topLeft, double topRight, double bottomLeft, double bottomRight,
    {Color color = Colors.white, double borderWidth = 0}) {
  return BoxDecoration(
      border: Border.all(color: color, width: borderWidth),
      borderRadius: BorderRadius.only(
          topLeft: Radius.circular(topLeft),
          topRight: Radius.circular(topRight),
          bottomLeft: Radius.circular(bottomLeft),
          bottomRight: Radius.circular(bottomRight)),
      image: const DecorationImage(
          image: AssetImage(XmmImg.commonBg), fit: BoxFit.fill));
}

Widget toolBarWidget(
  BuildContext context,
  String title, {
  Color boxColor = Colors.transparent,
  String? rightImage,
  GestureTapCallback? onRightTap,
  Color? titleColor,
  String? leftImage,
}) {
  return Container(
    margin: EdgeInsets.only(top: context.mediaQueryPadding.top),
    height: 44.w,
    alignment: Alignment.center,
    child: Row(
      children: [
        GestureDetector(
          child: Container(
            margin: const EdgeInsets.only(left: 20),
            width: 32.w,
            height: 32.w,
            padding: EdgeInsets.all(5.w),
            decoration: BoxDecoration(
              shape: BoxShape.circle,
              color: boxColor,
            ),
            child: Image.asset(leftImage ?? XmmImg.backIcon),
          ),
          onTap: () => Get.back(),
        ),
        const Expanded(child: SizedBox()),
        Text(
          title,
          style: TextStyle(
            fontSize: 18.sp,
            color: titleColor ?? const Color(0xFF404040),
          ),
        ),
        const Expanded(child: SizedBox()),
        Visibility(
          visible: rightImage != null,
          child: GestureDetector(
            onTap: onRightTap,
            child: Container(
              margin: const EdgeInsets.only(right: 20),
              width: 32.w,
              height: 32.w,
              padding: EdgeInsets.all(5.w),
              decoration: BoxDecoration(
                shape: BoxShape.circle,
                color: boxColor,
              ),
              child: rightImage != null
                  ? Image.asset(rightImage)
                  : const SizedBox(),
            ),
          ),
        )
      ],
    ),
  );
}

Widget getEmptyWidget() {
  return Center(
    child: Container(
      margin: EdgeInsets.only(bottom: 100.w),
      child: Image.asset(
        "assets/images/xmm_icon_empty.png",
        width: 195,
        height: 205,
      ),
    ),
  );
}
